package com.mixed.mixedserver.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Setter
@Getter
@Component
@ConfigurationProperties(prefix = "netty.server")
public class NettyConfig {
    // Getters and Setters
    private int port = 8081;
    private int bossThreads = 1;
    private int workerThreads = 8;
    private int soBacklog = 128;
    private boolean soKeepalive = true;
    private boolean tcpNodelay = true;
    
    private Heartbeat heartbeat = new Heartbeat();
    private Frame frame = new Frame();

    @Setter
    @Getter
    public static class Heartbeat {
        private int readerIdleTime = 60;
        private int writerIdleTime = 30;
        private int allIdleTime = 90;

    }
    
    @Setter
    @Getter
    public static class Frame {
        private int maxFrameLength = 1048576; // 1MB，支持更大的消息帧
        private int lengthFieldOffset = 0;
        private int lengthFieldLength = 4;
        private int lengthAdjustment = 0;
        private int initialBytesToStrip = 4;

    }
}